package com.medical.config;

import io.agora.media.RtcTokenBuilder;

public class AgoraTokenService {
    private static final String appId = "YOUR_APP_ID";
    private static final String appCertificate = "YOUR_APP_CERTIFICATE";

    public String generateToken(String channelName, String uid) {
        RtcTokenBuilder tokenBuilder = new RtcTokenBuilder();
        int expirationTimeInSeconds = 3600; // 1 hour
        int currentTimestamp = (int) (System.currentTimeMillis() / 1000);
        int privilegeExpiredTs = currentTimestamp + expirationTimeInSeconds;

        return tokenBuilder.buildTokenWithUid(appId, appCertificate, channelName, Integer.parseInt(uid), RtcTokenBuilder.Role.Role_Publisher, privilegeExpiredTs);
    }
}
